package com.mail.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mail.dubbo.mapper.SmsCouponHistoryMapper;
import com.mail.model.db.SmsCouponHistory;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author yan
 * @date 2022/06/23 09:40
 **/
@DubboService
public class SmsCouponHistoryApiImpl implements SmsCouponHistoryApi {
    @Autowired
    private SmsCouponHistoryMapper mapper;

    @Override
    public Page<SmsCouponHistory> list(Long pageNum, Long pageSize, SmsCouponHistory smsCouponHistory) {
        Page<SmsCouponHistory> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<SmsCouponHistory> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(smsCouponHistory.getCouponId() != null, SmsCouponHistory::getCouponId, smsCouponHistory.getCouponId());
        wrapper.eq(smsCouponHistory.getGetType() != null, SmsCouponHistory::getGetType, smsCouponHistory.getGetType());
        wrapper.eq(smsCouponHistory.getOrderSn() != null, SmsCouponHistory::getOrderSn, smsCouponHistory.getOrderSn());
        mapper.selectPage(page,wrapper);
        return page;
    }
}
